<?php 
namespace app\admin\controller;
use think\Controller;
use think\Session;
use app\common\model\AdminUser;
use app\common\model\AdminLog;
use think\Request;
/**
 * @Author: YeMiao
 * @Date:   2017-07-29 16:12:26
 * @Last Modified by:   YeMiao
 * @Last Modified time: 2017-11-06 15:41:11
 */



class Login extends Controller{
	public function index(){
		$User = new AdminUser();
		$log = new AdminLog();
		if(Request::instance()->isPost()){

			$find = $User->find_user(input('post.user'));
			if($find){
				if($find['password'] = md5(input('post.password'))){
					Session::set('user',input('post.user'));
					Session::set('group',$find['group']);
					Session::set('ontime',time());
					Session::set('state',$find['state']);
					$log->add_log('登录',input('post.user'));
					$this->success('登录成功','index/index');
					die;
				}
			}else{
				$this->error('用户名或密码错误','login/index');	
				die;			
			}
		}

		return $this->fetch();
	}
}


 ?>